'''
Author: goog
Date: 2021-12-15 21:18:14
LastEditTime: 2021-12-15 21:41:29
LastEditors: goog
Description: 
FilePath: /TensorRT_fast/DetectionFM/EAPM/EAPM.py
Time Limit Exceeded!
'''
import os
import json
def eapm(cfg, item, barcode):
    defect = "EAPM"
    abs_dir = cfg['abs_dir']
    config_path = os.path.join(abs_dir, 'DetectionFM/'+defect+'/'+defect+'.json')
    with open(config_path, 'r') as fp:
        config = json.load(fp)
        if barcode not in config.keys():
            barcode = 'C50'+barcode[3:]
        flag = config[barcode]['exist']
    if 'eapm' not in  item.keys():
        return False == flag
        
    eapm_position = item['eapm']
    if len(eapm_position)>0:
        return True == flag
    else: 
        return False == flag